﻿using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MyCompany.WebCrawler.Domain;

namespace MyCompany.WebCrawler.Test.Domain.DownloaderTests.Given_Page
{
    [TestClass]
    public class When_AdjustBaseUrl : Context
    {
        private Downloader downloader;

        public override void Arrange()
        {
            downloader = new Downloader
                {
                    BaseUrl = "http://google.com"
                };
        }

        [TestMethod]
        public void Then_CurrentLinkIsOk()
        {
            var fullLink = downloader.UpdateLink("ads");
            fullLink.Should().Be("http://google.com/ads");
        }

        [TestMethod]
        public void Then_RootLinkIsOk()
        {
            var fullLink = downloader.UpdateLink("/ads/1.html");
            fullLink.Should().Be("http://google.com/ads/1.html");
        }

        [TestMethod]
        public void Then_ReletiveLinkIsOk()
        {
            downloader.BaseUrl = "http://google.com/ads/1.html";

            var fullLink = downloader.UpdateLink("compain/2.html");
            fullLink.Should().Be("http://google.com/ads/compain/2.html");
        }

        [TestMethod]
        public void Then_FullReletiveLinkIsOk()
        {
            downloader.BaseUrl = "http://google.com/ads/1.html";

            var fullLink = downloader.UpdateLink("/trend/2.html");
            fullLink.Should().Be("http://google.com/trend/2.html");
        }

    }
}